package com.agentframework.core.environment;

import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicInteger;

public class AsyncTaskTracker {

    private final ConcurrentHashMap<String, AtomicInteger> taskCounts = new ConcurrentHashMap<>();

    public void registerTask(String agentId) {
        taskCounts.computeIfAbsent(agentId, k -> new AtomicInteger(0)).incrementAndGet();
    }

    public void completeTask(String agentId) {
        AtomicInteger count = taskCounts.get(agentId);
        if (count != null) {
            count.decrementAndGet();
        }
    }

    public boolean hasPendingTasks(String agentId) {
        AtomicInteger count = taskCounts.get(agentId);
        return count != null && count.get() > 0;
    }

} 